package com.getinstaliker.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.getinstaliker.instagram.InstagramLogin;
import com.getinstaliker.instagram.InstagramLogin.AuthAuthenticationListener;
import com.getinstaliker.instagram.SessionStore;
import com.getinstaliker.screen.SplashFragment;

/**
 * The Class SplashActivity.
 * @author HuanND
 */
public class SplashFragmentActivity extends BaseFragmentActivity {
	
	/**
	 * On create.
	 *
	 * @param savedInstanceState the saved instance state
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(SessionStore.getInstance().getInstaAccessToken()!=null){
			openMainActivity();
		}else{
			switchContent(new SplashFragment(), false);
		}
	}
	
	/**
	 * Start instagram app.
	 */
	public void startInstagramApp(){
		new InstagramLogin(this,new AuthAuthenticationListener() {
			
			@Override
			public void onSuccess() {
				openMainActivity();
			}
			
			@Override
			public void onFail(String error) {
			}
		});
	}

	/**
	 * Open main activity.
	 */
	public void openMainActivity(){
		startActivity(new Intent(this,MainFragmentActivity.class));
		finish();
	}
	
}

